package com.example.canal.service;


import com.example.canal.event.EventInfo;

/**
 * 事件处理上下文对象 -- 策略模式
 *
 * @author maowei
 * @date 2020/9/7
 * @time 14:08
 */
public class EventHandleContext {

    private IEventHandler handler;

    private final EventInfo eventInfo;

    public EventHandleContext(IEventHandler handler, EventInfo eventInfo) {
        this.handler = handler;
        this.eventInfo = eventInfo;
    }

    public void setHandler(IEventHandler handler) {
        this.handler = handler;
    }

    public void handle() {
        handler.handle(eventInfo);
    }

}
